home *** CD-ROM | disk | FTP | other *** search
- { Program THELP was written by a Mr. Glenn Wood of the Greenville PC Club of
- Greenville, Texas. Mr. Wood learned the principles demonstrated in this
- program in a class taught by Mr. Stephen R. Davis, also of Greenville.
- One suggestion for a way to improve this program can be inferred from Mr.
- Davis's own comment about the program in a letter he wrote to Borland
- International: "Note that the window opening is slow because in our class we
- insisted on using the BIOS interrupt rather than go directly to screen memory
- ourselves." }
-
- PROGRAM THELP;
-
- {$C-}
- {$K-}
-
-
- {VARIABLE SECTION FOR 'THELP'}
-
- type
- text80 = string[80];
- RegType = record
- ax,bx,cx,dx,bp,si,di,ds,es,flags:integer
- end;
- HalfRegType = record
- al,ah,bl,bh,cl,ch,dl,dh:byte
- end;
- IntrType = record
- ip,cs : integer
- end;
-
- const
- EntryChar = 19; { ALT 'R' }
- Escape = 0;
- FirstRow = 3;
- FirstCol = 11;
- WindowWidth = 60;
- WindowLength = 18;
- Dr = 3;
- Mr = 12;
- Cr = $0D;
- UserInt = $66;
- KybdInt = $16;
- ProgSize : integer = $A000; { approx. program size }
-
- Regs : regtype = (ax:0;bx:0;cx:0;dx:0;bp:0;si:0;di:0;ds:0;es:0;flags:0);
- SaveDS :integer = 0;
-
- var
- SaveReg : RegType;
- SaveHalf : HalfRegType absolute SaveReg;
- HalfReg : HalfRegType absolute regs;
- i,j,x,y : integer;
- CursorPos : integer;
- Selection : integer;
- savebuf : array[1..windowwidth] of array[1..windowlength] of integer;
-
-
- { MISC. PROCEDURES AND FUNTIONS FOR THELP }
-
- procedure Bright(line:text80);
- begin
- textcolor(15);
- write(line);
- textcolor(7);
- end;
-
- procedure PrintHeading;
- begin
- bright('T'); write('URBO Pascal ');
- bright('Help '); write('Ver 2.0');
- end;
-
- procedure PrintMCS;
- begin
- bright('M'); write('agnum ');
- bright('C'); write('ustom ');
- bright('S'); write('oftware');
- end;
-
- procedure Border;
- begin
- GotoXY(1,1); {clear the window now}
- Write(chr(218));
- for i:=2 to windowwidth-1 do Write(chr(196));
- Write(chr(191));
- for i:=2 to windowlength-1 do
- begin
- GotoXY(1, i); Write(chr(179));
- for j := 2 to windowwidth-1 do
- Write(' ');
- GotoXY(windowwidth, i); Write(chr(179));
- end;
- GotoXY(1, windowlength);
- Write(chr(192));
- for i:=2 to windowwidth-1 do Write(chr(196));
- Write(chr(217));
- END;
-
- function GetScreenChar:integer;
- begin
- savereg.ax := $0800; {9 -> get character/attr @ cursor}
- savereg.bx := 0;
- Intr($10,savereg);
- GetScreenChar := savereg.ax
- end;
-
- procedure PutScreenChar(input:integer);
- begin
- savereg.ax := $0900 + (input and $FF); {a -> put character/attr @ cursor}
- savereg.bx := input shr 8; {put the attrib in bl and 0 in bh}
- savereg.cx := 1;
- Intr($10,savereg)
- end;
-
- procedure OpenWindow;
- begin
- window (firstcol, firstrow, firstcol+windowwidth, firstrow+windowlength);
- for j := 1 to windowlength do
- for i := 1 to windowwidth do
- begin
- GoToXY(i,j);
- savebuf[i][j] := GetScreenChar {get a attribute/character at the cursor}
- end;
- border;
- window (firstcol+1,firstrow+1,firstcol+windowwidth-2,firstrow+windowlength-2);
- gotoxy(1,1);
- end;
-
- procedure closewindow;
- begin
- window (firstcol, firstrow, firstcol+windowwidth, firstrow+windowlength);
- for j := 1 to windowlength do
- for i := 1 to windowwidth do
- begin
- GoToXY(i,j);
- PutScreenChar(savebuf[i][j])
- end
- end;
-
-
- { MENU PRINT PROCEDURES FOR THELP }
-
- procedure PrintMenu(number:integer);
- begin
- case number of
- 0 : begin
- gotoxy(mr+3,2); PrintHeading;
- gotoxy(mr+7,3); PrintMCS;
- gotoxy(mr+12,5); write('MAIN MENU');
- gotoxy(mr,6); write('<1> Edit Commands');
- gotoxy(mr,7); write('<2> Syntax Structure');
- gotoxy(mr,8); write('<3> Standard Procedures/Functions');
- gotoxy(mr,9); write('<4> Compiler Directives');
- gotoxy(mr,10); write('<5> Runtime Errors');
- gotoxy(mr,11); write('<6> I/O Errors');
- gotoxy(mr,12); write('<7> Standard Identifiers');
- gotoxy(mr,13); write('<8> Version 2 Additions Part I');
- gotoxy(mr,14); write('<9> Version 2 Additions Part II');
- end;
- 1 : begin
- gotoxy(mr+3,2); PrintHeading;
- gotoxy(mr+7,3); PrintMCS;
- gotoxy(mr+7,5); write('EDITOR COMMANDS MENU');
- gotoxy(mr,7); write('<1> Cursor Movements Part I');
- gotoxy(mr,8); write('<2> Cursor Movements Part II');
- gotoxy(mr,9); write('<3> Insert and Delete Commands');
- gotoxy(mr,10); write('<4> Block Commands');
- gotoxy(mr,11); write('<5> Miscellaneous and Options');
- end;
-
- 2 : begin
- gotoxy(mr+3,2); PrintHeading;
- gotoxy(mr+7,3); PrintMCS;
- gotoxy(mr+6,5); write('SYNTAX STRUCTURE MENU');
- gotoxy(mr,6); write('<1> TYPE');
- gotoxy(mr,7); write('<2> CONST');
- gotoxy(mr,8); write('<3> VAR');
- gotoxy(mr,9); write('<4> WITH DO and CASE');
- gotoxy(mr,10); write('<5> REPEAT UNTIL and WHILE DO');
- gotoxy(mr,11); write('<6> IF THEN ELSE and FOR TO DO');
- gotoxy(mr,12); write('<7> PROGRAM, PROCEDURE and FUNCTION');
- gotoxy(mr,13); write('<8> Program Structure');
- end;
-
- 3 : begin
- gotoxy(mr+3,2); PrintHeading;
- gotoxy(mr+7,3); PrintMCS;
- gotoxy(mr,5); write('STANDARD PROCEDURES/FUNCTIONS MENU');
- gotoxy(mr,6); write('<1> Input/Output Procedures');
- gotoxy(mr,7); write('<2> Arithmetic Functions');
- gotoxy(mr,8); write('<3> Scalar Functions/Heap Control');
- gotoxy(mr,9); write('<4> String Procedures and Functions');
- gotoxy(mr,10); write('<5> File Handling Procedures');
- gotoxy(mr,11); write('<6> File Handling Functions');
- gotoxy(mr,12); write('<7> Transfer/Screen Procs & Funcs');
- gotoxy(mr,13); write('<8> Miscellaneous Proc/Func Part I');
- gotoxy(mr,14); write('<9> Miscellaneous Functions Part II');
- end;
- end;
- repeat
- gotoxy(19,15); write('Enter Selection ? ');
- savereg.ax := $00;
- Intr(userint,savereg);
- selection := savehalf.ah - 1;
- until ((selection in [0..9]) and (number in [0,3]))
- or ((selection in [0..5]) and (number = 1))
- or ((selection in [0..8]) and (number = 2));
- clrscr;
- end;
-
-
- procedure Wait;
- begin
- gotoxy(14,16); write('PRESS <ESC> TO RETURN TO MENU');
- repeat
- savereg.ax := 0;
- Intr(userint,savereg);
- until savehalf.ah = $01;
- clrscr;
- end;
-
- procedure CursorMoveI;
- begin
- gotoxy(dr,2); write('CURSOR MOVEMENTS Part I :');
- gotoxy(dr,4); write(' Character left Ctrl-S -> ',#$1B);
- gotoxy(dr,5); write(' Alternative Ctrl-H -> ');
- gotoxy(dr,6); write(' Character right Ctrl-D -> ',#$1A);
- gotoxy(dr,7); write(' Word left Ctrl-A -> Ctrl ',#$1B);
- gotoxy(dr,8); write(' Word right Ctrl-F -> Ctrl ',#$1A);
- gotoxy(dr,9); write(' Line up Ctrl-E -> ',#$18);
- gotoxy(dr,10); write(' Line down Ctrl-X -> ',#$19);
- gotoxy(dr,11); write(' Scroll up Ctrl-W -> ');
- gotoxy(dr,12); write(' Scroll down Ctrl-Z -> ');
- gotoxy(dr,13); write(' Page up Ctrl-R -> PgUp');
- gotoxy(dr,14); write(' Page down Ctrl-C -> PgDn');
- Wait;
- end;
-
- procedure CursorMoveII;
- begin
- gotoxy(dr,2); write('CURSOR MOVEMENTS Part II :');
- gotoxy(dr,4); write(' To left on line Ctrl-Q Ctrl-S -> Home');
- gotoxy(dr,5); write(' To right on line Ctrl-Q Ctrl-D -> End');
- gotoxy(dr,6); write(' To top of page Ctrl-Q Ctrl-E -> Ctrl Home');
- gotoxy(dr,7); write(' To bottom of page Ctrl-Q Ctrl-X -> Ctrl End');
- gotoxy(dr,8); write(' To top of file Ctrl-Q Ctrl-R -> Ctrl PgUp');
- gotoxy(dr,9); write(' To end of file Ctrl-Q Ctrl-C -> Ctrl PgDn');
- gotoxy(dr,10); write(' To top of block Ctrl-Q Ctrl-B -> ');
- gotoxy(dr,11); write(' To end of block Ctrl-Q Ctrl-K -> ');
- gotoxy(dr,12); write(' To last cur.pos. Ctrl-Q Ctrl-P -> ');
- Wait;
- end;
-
- procedure InsertDelete;
- begin
- gotoxy(dr,2); write('INSERT and DELETE :');
- gotoxy(dr,4); write(' Insert mode on/off Ctrl-V -> Ins');
- gotoxy(dr,5); write(' Insert line Ctrl-N -> ');
- gotoxy(dr,6); write(' Delete line Ctrl-Y -> ');
- gotoxy(dr,7); write(' Del to end of line Ctrl-Q Ctrl-Y -> ');
- gotoxy(dr,8); write(' Delete right word Ctrl-T -> ');
- gotoxy(dr,9); write(' Del char under cursor Ctrl-G -> Del');
- gotoxy(dr,10); write(' Delete left character <DEL> -> ');
- gotoxy(dr,11); write(' Alternative nothing -> ');
- Wait;
- end;
-
- procedure BlockCommands;
- begin
- gotoxy(dr,2); write('BLOCK COMMANDS :');
- gotoxy(dr,4); write(' Mark block begin Ctrl-K Ctrl-B -> F7');
- gotoxy(dr,5); write(' Mark block end Ctrl-K Ctrl-K -> F8');
- gotoxy(dr,6); write(' Mark single word CON